home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / IOInterface / dialogAbout.icl < prev    next >
Encoding:
Modula Implementation  |  1997-02-06  |  2.8 KB  |  88 lines  |  [TEXT/3PRM]

  1. implementation module dialogAbout;
  2.  
  3.  
  4. import    StdBool, StdInt;
  5. import    ioState, dialogAccess, dialogInternal;
  6. from    dialogDevice    import DoModalDialog;
  7.  
  8.  
  9. AboutDialogID    :== -1;
  10.  
  11. DummyDialogH    ::    DialogHandle s io;
  12. DummyDialogH    =    DialogH 0 "" Modal (0,0,0,0) [] [] (DialogRest Command [] 0);
  13.  
  14.  
  15. //    AboutDialogToDialogHandle converts an AboutDialog into a DialogHandle.
  16.  
  17. AboutDialogToDialogHandle :: !(DialogDef s (IOState s)) -> DialogHandle s (IOState s);
  18. AboutDialogToDialogHandle (AboutDialog an pd fs help)
  19.     =    DialogH AboutDialogID an Modal (0,0,0,0) [] [icon, ok : hbut] (DialogRest Command [] 2);
  20.     where {
  21.         icon= DialogIconButton 1 Center pd (AboutLook fs) Unable AboutOK;
  22.         ok  = DialogButton 2 Center "OK" Able AboutOK;
  23.         hbut= MakeAboutHelpButton help;
  24.     };
  25.  
  26. AboutLook :: ![DrawFunction] !SelectState -> [DrawFunction];
  27. AboutLook drawfs _ = drawfs;
  28.  
  29. // AboutOK    :: !DialogInfo !*s !(IOState *s) -> (!*s,!IOState *s);
  30. AboutOK ddef s io =  (s, DeviceCloseDialog io);
  31.  
  32. MakeAboutHelpButton    :: !(AboutHelpDef s (IOState s)) -> [DialogItem s (IOState s)];
  33. MakeAboutHelpButton NoHelp =  [];
  34. MakeAboutHelpButton (AboutHelp title helpf)
  35.     =  [DialogButton 3 (RightTo 2) title Able (AboutHelpFunc helpf)];
  36.  
  37. // AboutHelpFunc    :: !(*s ->  (IOState *s) -> (*s,IOState *s) ) !DialogInfo !*s !(IOState *s)
  38. //   -> (!*s,!IOState *s);
  39. AboutHelpFunc helpf ddef s io =  helpf s (DeviceCloseDialog io);
  40.  
  41. DeviceCloseDialog :: !(IOState s) -> IOState s;
  42. DeviceCloseDialog ioState
  43. |    not found    = ioState1;
  44.                 = DeactivateDialog dRep ioState1;
  45.     where {
  46.         (found,dRep,ioState1) = IOStateRemoveActiveDialog ioState;
  47.     };
  48.  
  49.  
  50. //    OpenAboutDialog opens the About... dialog
  51.  
  52. OpenAboutDialog :: !*s !(IOState *s) -> (!*s, !IOState *s);
  53. OpenAboutDialog s ioState
  54. |    found    = DoModalDialog (DialogHandleToDialogDef about) s ioState1;
  55.             = DoModalDialog defaultAboutDef s ioState1;
  56.     where {
  57.         (found,about)    = GetAboutDialog dHs;
  58.         (dHs,ioState1)    = IOStateGetDialogs ioState;
  59.         defaultAboutDef    = CommandDialog AboutDialogID "" [] 2 [
  60.                                 StaticText     1 Center "This is a Clean program.",
  61.                                 DialogButton 2 Center "OK" Able AboutOK ];
  62.     };
  63.  
  64. GetAboutDialog :: !(DialogHandles s) -> (!Bool, !DialogHandle s (IOState s));
  65. GetAboutDialog [(dH=:DialogH id _ _ _ _ _ _,_) : dHs]
  66. |    id == AboutDialogID    = (True, dH);
  67.                         = GetAboutDialog dHs;
  68. GetAboutDialog _ = (False, DummyDialogH);
  69.  
  70.  
  71. //    Return the application name as defined in the AboutDialog.
  72.  
  73. IOStateGetApplicationName :: !(IOState s) -> (!String, !IOState s);
  74. IOStateGetApplicationName ioState
  75. |    not found    = ("", ioState1);
  76.                 = (AboutHandleGetApplicationName about, ioState1);
  77.     where {
  78.         (dHs, ioState1)= IOStateGetDialogs ioState;
  79.         (found, about) = GetAboutDialog dHs;
  80.     };
  81.  
  82. AboutHandleGetApplicationName :: !(DialogHandle s (IOState s)) -> String;
  83. AboutHandleGetApplicationName (DialogH _ name _ _ _ _ _) = name;
  84.  
  85.  
  86.  
  87.